#!/usr/bin/python3

import sx126x_driver
import time

sx126x_driver.Open()
sx126x_driver.StartReceive()

irq = 0

sendbuf = b'abcde'

while 1:
    time.sleep(0.001)
    irq = sx126x_driver.CheckIRQ()
    if (irq != 0):
        print(hex(irq))
        print(sx126x_driver.GetPacketStatus())
        print(sx126x_driver.Read())
        

        sx126x_driver.Write(sendbuf)
        # wait sent
        while (sx126x_driver.CheckIRQ() == 0):
            time.sleep(0.001)

        sx126x_driver.StartReceive()

